#ifndef EDITROLEDLG_H
#define EDITROLEDLG_H

#include "Entity/DictData.h"
#include "api/systemManager/rolemanagerapi.h"
#include <QDialog>
#include <QDebug>

namespace Ui {
class EditRoleDlg;
}

class EditRoleDlg : public QDialog
{
    Q_OBJECT

public:
    explicit EditRoleDlg(QString id,QList<DictData> dictList,QWidget *parent = nullptr);
    ~EditRoleDlg();
signals:
    void success();

private slots:
    void on_btn_cancel_clicked();
    void treeItemChanged(QTreeWidgetItem *item,int column);
    void on_treeWidget_itemExpanded(QTreeWidgetItem *item);
    void on_treeWidget_itemCollapsed(QTreeWidgetItem *item);

    void on_checkBox_expand_clicked();

    void on_checkBox_selectAll_clicked();

    void on_checkBox_fatherAndSon_clicked();

    void on_btn_ok_clicked();

private:
    Ui::EditRoleDlg *ui;
    QString id;
    QList<DictData> dictList;
    RoleManagerApi roleManagerApi;
    Role *role;
    QNetworkReply *r;
    QJsonArray arrTree;
    int treeWidgetHeight;
    bool fatherAndSonLink = 1;
    QList<int> menuIds;
    Utils utils;
    void init();
    void treeSelect();
    void setTreeWidget(QJsonArray arr,QTreeWidgetItem *parent);

};

#endif // EDITROLEDLG_H
